Added a test to verify that devices come and go from block-list
authordan@guaranine.beaverton.ibm.com <dan@guaranine.beaverton.ibm.com>
Fri, 18 Nov 2005 12:02:01 +0000 (13:02 +0100)
committerdan@guaranine.beaverton.ibm.com <dan@guaranine.beaverton.ibm.com>
Fri, 18 Nov 2005 12:02:01 +0000 (13:02 +0100)
as they are block-attach'd and block-detach'd.

tools/xm-test/tests/block-list/06_block-list_checkremove_pos.py [new file with mode: 0644]
tools/xm-test/tests/block-list/Makefile.am

diff --git a/tools/xm-test/tests/block-list/06_block-list_checkremove_pos.py b/tools/xm-test/tests/block-list/06_block-list_checkremove_pos.py
new file mode 100644 (file)
index 0000000..14956fc
--- /dev/null
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Dan Smith <danms@us.ibm.com>
+
+from XmTestLib import *
+
+domain = XmTestDomain()
+
+try:
+    domain.start()
+except DomainError, e:
+    FAIL(str(e))
+
+try:
+    console = XmConsole(domain.getName())
+except ConsoleError, e:
+    FAIL(str(e))
+
+s, o = traceCommand("xm block-list %s" % domain.getName())
+if s != 0:
+    FAIL("block-list returned !0 when no devices attached")
+if o:
+    FAIL("block-list without devices reported something!")
+
+s, o = traceCommand("xm block-attach %s phy:/dev/ram0 hda1 w" % domain.getName())
+if s != 0:
+    FAIL("Unable to attach /dev/ram0->hda1")
+
+s, o = traceCommand("xm block-list %s" % domain.getName())
+if s != 0:
+    FAIL("block-list failed")
+if not o.find("769"):
+    FAIL("block-list didn't show the block device I just attached!")
+
+s, o = traceCommand("xm block-attach %s phy:/dev/ram1 hda2 w" % domain.getName())
+if s != 0:
+    FAIL("Unable to attach /dev/ram1->hda2")
+
+s, o = traceCommand("xm block-list %s" % domain.getName())
+if s != 0:
+    FAIL("block-list failed")
+if not o.find("770"):
+    FAIL("block-list didn't show the other block device I just attached!")
+
+s, o = traceCommand("xm block-detach %s 769" % domain.getName())
+if s != 0:
+    FAIL("block-destroy of hda1 failed")
+
+s, o = traceCommand("xm block-list %s" % domain.getName())
+if s != 0:
+    FAIL("block-list failed after detaching a device")
+if o.find("769"):
+    FAIL("hda1 still shown in block-list after detach!")
+if not o.find("770"):
+    FAIL("hda2 not shown after detach of hda1!")
+
+s, o = traceCommand("xm block-detach %s 770" % domain.getName())
+if s != 0:
+    FAIL("block-list failed after detaching another device")
+if o.find("770"):
+    FAIL("hda2 still shown in block-list after detach!")
+if o:
+    FAIL("block-list still shows something after all devices detached!")
+    
+
index 9bf8be6fb031ed6455b7a57006dd4f6385f41f4f..9e303af6f85c48f03b85ca546202816054faf4bb 100644 (file)
@@ -5,7 +5,8 @@ TESTS = 01_block-list_pos.test  \
        02_block-list_attachbd_pos.test \
        03_block-list_anotherbd_pos.test \
        04_block-list_nodb_pos.test \
-       05_block-list_nonexist_neg.test
+       05_block-list_nonexist_neg.test \
+       06_block-list_checkremove_pos.test
 
 XFAIL_TESTS =